import 'package:flutter/cupertino.dart';
import 'package:get/get.dart';
import 'package:get/get_core/src/get_main.dart';
import 'package:qianyi/entity/message/Message.dart';
import 'package:qianyi/state/token.dart';

import '../../../entity/message/inner/CommentEntityInner.dart';
import '../../../entity/message/inner/FollowEntity.dart';
import '../../../entity/message/inner/LikeAndCollectEntity.dart';
import '../../../network/http_config.dart';
import '../../../network/http_entity.dart';
import '../../../network/http_manager.dart';
import '../../../ui/widget/custom_refresh_mixin.dart';


class CommentInnerViewModel extends ChangeNotifier with CustomRefreshMixin{

  TextEditingController introduceController = TextEditingController();
  TokenController tokenController = Get.find();
  @override
  Future<List> requestList(int page) async {
    List tempL = [];
    Map<String, dynamic> params = {};

    // String id = UserManager.userEntity!.userInfo!.id!;

    params["uid"] = tokenController.uid;;

    HttpEntity? result = await HttpManager.getInstance().request(url: "/platform/comment/getAllReplyComment/${page}/10", params: params,method: Method.get) as HttpEntity;
    if(result.getOriData()['code'] == 201) {
      return tempL;
    };
    CommentEntityList listResult = CommentEntityList.fromJson(result.getOriData()["data"]);
    List<CommentEntityInner>? temps = listResult.comments!; // 这里不需要强制类型转换
    if (temps != null) {
      tempL.addAll(temps);
    }


    return tempL;
  }


  @override
  void onRequestComplete() {
    notifyListeners();
  }

  void onrefreshXt() {
    this.onRefresh();
    notifyListeners();
  }

}